package com.gt.xmall.model;

import javax.persistence.*;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;


@Entity
@Table(name = "gtd_project")
public class GtdProject extends IdEntity implements  Serializable{
	 
	
	 
 
	

 
	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	
	private java.lang.String name;
	
	private java.lang.String description;
	
	private java.util.Date startTime;
	
	private java.util.Date endTime;
	//columns END
 

	
	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "description", unique = false, nullable = true, insertable = true, updatable = true, length = 2147483647)
	public java.lang.String getDescription() {
		return this.description;
	}
	
	public void setDescription(java.lang.String value) {
		this.description = value;
	}
	
	 
	
	@Column(name = "start_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getStartTime() {
		return this.startTime;
	}
	
	public void setStartTime(java.util.Date value) {
		this.startTime = value;
	}
	
	 
	
	@Column(name = "end_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getEndTime() {
		return this.endTime;
	}
	
	public void setEndTime(java.util.Date value) {
		this.endTime = value;
	}
	
	
	private Set<GtdCollection> gtdCollections = new HashSet<GtdCollection>(0);
	public void setGtdCollections(Set<GtdCollection> gtdCollection){
		this.gtdCollections = gtdCollection;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "gtdProject")
	public Set<GtdCollection> getGtdCollections() {
		return gtdCollections;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("Name",getName())
			.append("Description",getDescription())
			.append("StartTime",getStartTime())
			.append("EndTime",getEndTime())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof GtdProject == false) return false;
		if(this == obj) return true;
		GtdProject other = (GtdProject)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
}

